package com.foreknow.demo5;

public class TestStudent {
    public static void main(String[] args) {
        Student s = new Student();
        //通过set方法给对象中的属性设置值
        s.setId(1001);
        s.setName("fender");
        s.setPhone("12121212");
        s.setEmail("zjjlive123@163.com");
        s.setTitle("test");

        Student s1 = new Student();
        //通过set方法给对象中的属性设置值
        s1.setId(1002);
        s1.setName("gibson");
        s1.setPhone("11111111111");
        s1.setEmail("zjjlive@163.com");
        s1.setTitle("test123");

        Student s2 = new Student();
        //通过set方法给对象中的属性设置值
        s2.setId(1003);
        s2.setName("yamaha");
        s2.setPhone("2222222222");
        s2.setEmail("yamaha@163.com");
        s2.setTitle("test345");

        //将以上的三个学生对象保存到数组中  Student[] ss = {s,s1,s2};  Student[] sss = new Student[]{s,s1,s2};
        Student[] students = new Student[3];
        //将对象保存到数组中
        students[0] = s;
        students[1] = s1;
        students[2] = s2;
        //遍历数组
        for(int i = 0;i<students.length;i++) {
            Student stu = students[i];
            System.out.println(stu.getId() + "--" + stu.getName());
        }

        System.out.println("-------------------------------------------------");

        for( Student stu:students) {
            System.out.println(stu.getId() + "--" + stu.getName());
        }










        //获取对象中的属性值
        int id = s.getId();
        String name = s.getName();
        String email = s.getEmail();
        String title = s.getTitle();
        System.out.println(id + "--" + name + "--" + email + "--" +title);


    }
}
